package com.sys.server.modules.controller;

import com.sys.server.common.annotation.Authentication;
import com.sys.server.common.annotation.Log;
import com.sys.server.common.config.CommonConfig;
import com.sys.server.common.model.R;
import com.sys.server.modules.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@Authentication
@Api(tags = "文件上传下载相关接口")
public class FileController {

    @Autowired
    private FileService fileService;

    @RequestMapping(value = "/dowmloadExportTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "用户信息模板文件下载")
    public void exportTemplateDownload(HttpServletResponse response) throws IOException {
        fileService.fileDownload(response, CommonConfig.getExcel_path());
    }

//    @PostMapping(value = "/upload")
//    @ApiOperation(value = "通用文件上传接口")
//    @Log(module = "文件", action = "文件上传", type = "文件上传")
//    public R appendUpload(MultipartFile file,
//                          @ApiParam(value = "类型（案例、行业标准..）") String type,
//                          @ApiParam(value = "编号") String id) {
//
//        System.out.println(id);
//        return fileService.fileUpload(file, CommonConfig.getAppendix_path(), type, id);
//    }

}
